home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 April: Mac OS SDK / Dev.CD Apr 00 SDK1.toast / Development Kits / Hardware / PowerManager DDK 1.0f1 / Interfaces&Libraries / Interfaces / MachineExceptions.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-08  |  6.8 KB  |  255 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        MachineExceptions.h
  3.  
  4.      Contains:    Processor Exception Handling Interfaces.
  5.  
  6.      Version:    Mac OS 8
  7.  
  8.      DRI:        Jim Murphy
  9.  
  10.      Copyright:    © 1993-1999 by Apple Computer, Inc., all rights reserved.
  11.  
  12.      Warning:    *** APPLE INTERNAL USE ONLY ***
  13.                  This file may contain unreleased API's
  14.  
  15.      BuildInfo:    Built by:            Scott Johnson
  16.                  On:                    10/8/99 11:26 AM
  17.                  With Interfacer:    3.0d13   (MPW PowerPC)
  18.                  From:                MachineExceptions.i
  19.                      Revision:        28
  20.                      Dated:            1/25/99
  21.                      Last change by:    ngk
  22.                      Last comment:    Add exportset attributes to functions.
  23.  
  24.      Bugs:        Report bugs to Radar component "System Interfaces", "Latest"
  25.                  List the version information (from above) in the Problem Description.
  26.  
  27. */
  28. #ifndef __MACHINEEXCEPTIONS__
  29. #define __MACHINEEXCEPTIONS__
  30.  
  31. #ifndef __MACTYPES__
  32. #include <MacTypes.h>
  33. #endif
  34.  
  35.  
  36.  
  37.  
  38. #if PRAGMA_ONCE
  39. #pragma once
  40. #endif
  41.  
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45.  
  46. #if PRAGMA_IMPORT
  47. #pragma import on
  48. #endif
  49.  
  50. #if PRAGMA_STRUCT_ALIGN
  51.     #pragma options align=power
  52. #elif PRAGMA_STRUCT_PACKPUSH
  53.     #pragma pack(push, 2)
  54. #elif PRAGMA_STRUCT_PACK
  55.     #pragma pack(2)
  56. #endif
  57.  
  58. /* Some basic declarations used throughout the kernel */
  59. typedef struct OpaqueAreaID*             AreaID;
  60. #if TARGET_OS_MAC
  61. /* Machine Dependent types for PowerPC: */
  62.  
  63. struct MachineInformationPowerPC {
  64.     UnsignedWide                     CTR;
  65.     UnsignedWide                     LR;
  66.     UnsignedWide                     PC;
  67.     unsigned long                     CR;
  68.     unsigned long                     XER;
  69.     unsigned long                     MSR;
  70.     unsigned long                     MQ;
  71.     unsigned long                     ExceptKind;
  72.     unsigned long                     DSISR;
  73.     UnsignedWide                     DAR;
  74.     UnsignedWide                     Reserved;
  75. };
  76. typedef struct MachineInformationPowerPC MachineInformationPowerPC;
  77.  
  78. struct RegisterInformationPowerPC {
  79.     UnsignedWide                     R0;
  80.     UnsignedWide                     R1;
  81.     UnsignedWide                     R2;
  82.     UnsignedWide                     R3;
  83.     UnsignedWide                     R4;
  84.     UnsignedWide                     R5;
  85.     UnsignedWide                     R6;
  86.     UnsignedWide                     R7;
  87.     UnsignedWide                     R8;
  88.     UnsignedWide                     R9;
  89.     UnsignedWide                     R10;
  90.     UnsignedWide                     R11;
  91.     UnsignedWide                     R12;
  92.     UnsignedWide                     R13;
  93.     UnsignedWide                     R14;
  94.     UnsignedWide                     R15;
  95.     UnsignedWide                     R16;
  96.     UnsignedWide                     R17;
  97.     UnsignedWide                     R18;
  98.     UnsignedWide                     R19;
  99.     UnsignedWide                     R20;
  100.     UnsignedWide                     R21;
  101.     UnsignedWide                     R22;
  102.     UnsignedWide                     R23;
  103.     UnsignedWide                     R24;
  104.     UnsignedWide                     R25;
  105.     UnsignedWide                     R26;
  106.     UnsignedWide                     R27;
  107.     UnsignedWide                     R28;
  108.     UnsignedWide                     R29;
  109.     UnsignedWide                     R30;
  110.     UnsignedWide                     R31;
  111. };
  112. typedef struct RegisterInformationPowerPC RegisterInformationPowerPC;
  113.  
  114. struct FPUInformationPowerPC {
  115.     UnsignedWide                     Registers[32];
  116.     unsigned long                     FPSCR;
  117.     unsigned long                     Reserved;
  118. };
  119. typedef struct FPUInformationPowerPC    FPUInformationPowerPC;
  120.  
  121. union Vector128 {
  122. #ifdef __VEC__
  123.     vector unsigned long            v;
  124. #endif
  125.     unsigned long                     l[4];
  126.     unsigned short                     s[8];
  127.     unsigned char                     c[16];
  128. };
  129. typedef union Vector128                    Vector128;
  130.  
  131. struct VectorInformationPowerPC {
  132.     Vector128                         Registers[32];
  133.     Vector128                         VSCR;
  134.     UInt32                             VRsave;
  135. };
  136. typedef struct VectorInformationPowerPC    VectorInformationPowerPC;
  137. /* Exception related declarations */
  138. enum {
  139.     kWriteReference                = 0,
  140.     kReadReference                = 1,
  141.     kFetchReference                = 2,
  142.     writeReference                = kWriteReference,                /* Obsolete name*/
  143.     readReference                = kReadReference,                /* Obsolete name*/
  144.     fetchReference                = kFetchReference                /* Obsolete name*/
  145. };
  146.  
  147.  
  148. typedef unsigned long                     MemoryReferenceKind;
  149.  
  150. struct MemoryExceptionInformation {
  151.     AreaID                             theArea;
  152.     LogicalAddress                     theAddress;
  153.     OSStatus                         theError;
  154.     MemoryReferenceKind             theReference;
  155. };
  156. typedef struct MemoryExceptionInformation MemoryExceptionInformation;
  157. enum {
  158.     kUnknownException            = 0,
  159.     kIllegalInstructionException = 1,
  160.     kTrapException                = 2,
  161.     kAccessException            = 3,
  162.     kUnmappedMemoryException    = 4,
  163.     kExcludedMemoryException    = 5,
  164.     kReadOnlyMemoryException    = 6,
  165.     kUnresolvablePageFaultException = 7,
  166.     kPrivilegeViolationException = 8,
  167.     kTraceException                = 9,
  168.     kInstructionBreakpointException = 10,
  169.     kDataBreakpointException    = 11,
  170.     kIntegerException            = 12,
  171.     kFloatingPointException        = 13,
  172.     kStackOverflowException        = 14,
  173.     kTaskTerminationException    = 15,
  174.     kTaskCreationException        = 16
  175. };
  176.  
  177. #if OLDROUTINENAMES
  178. enum {
  179.     unknownException            = kUnknownException,            /* Obsolete name*/
  180.     illegalInstructionException    = kIllegalInstructionException,    /* Obsolete name*/
  181.     trapException                = kTrapException,                /* Obsolete name*/
  182.     accessException                = kAccessException,                /* Obsolete name*/
  183.     unmappedMemoryException        = kUnmappedMemoryException,        /* Obsolete name*/
  184.     excludedMemoryException        = kExcludedMemoryException,        /* Obsolete name*/
  185.     readOnlyMemoryException        = kReadOnlyMemoryException,        /* Obsolete name*/
  186.     unresolvablePageFaultException = kUnresolvablePageFaultException, /* Obsolete name*/
  187.     privilegeViolationException    = kPrivilegeViolationException,    /* Obsolete name*/
  188.     traceException                = kTraceException,                /* Obsolete name*/
  189.     instructionBreakpointException = kInstructionBreakpointException, /* Obsolete name*/
  190.     dataBreakpointException        = kDataBreakpointException,        /* Obsolete name*/
  191.     integerException            = kIntegerException,            /* Obsolete name*/
  192.     floatingPointException        = kFloatingPointException,        /* Obsolete name*/
  193.     stackOverflowException        = kStackOverflowException,        /* Obsolete name*/
  194.     terminationException        = kTaskTerminationException,    /* Obsolete name*/
  195.     kTerminationException        = kTaskTerminationException        /* Obsolete name*/
  196. };
  197.  
  198. #endif  /* OLDROUTINENAMES */
  199.  
  200.  
  201. typedef unsigned long                     ExceptionKind;
  202.  
  203. union ExceptionInfo {
  204.     MemoryExceptionInformation *    memoryInfo;
  205. };
  206. typedef union ExceptionInfo                ExceptionInfo;
  207.  
  208. struct ExceptionInformationPowerPC {
  209.     ExceptionKind                     theKind;
  210.     MachineInformationPowerPC *        machineState;
  211.     RegisterInformationPowerPC *    registerImage;
  212.     FPUInformationPowerPC *            FPUImage;
  213.     ExceptionInfo                     info;
  214.     VectorInformationPowerPC *        vectorImage;
  215. };
  216. typedef struct ExceptionInformationPowerPC ExceptionInformationPowerPC;
  217.  
  218. typedef ExceptionInformationPowerPC     ExceptionInformation;
  219. typedef MachineInformationPowerPC         MachineInformation;
  220. typedef RegisterInformationPowerPC         RegisterInformation;
  221. typedef FPUInformationPowerPC             FPUInformation;
  222. typedef VectorInformationPowerPC         VectorInformation;
  223. /* 
  224.     Note:    An ExceptionHandler is NOT a UniversalProcPtr.
  225.             It must be a PowerPC function pointer with NO routine descriptor. 
  226. */
  227. typedef CALLBACK_API_C( OSStatus , ExceptionHandler )(ExceptionInformationPowerPC *theException);
  228. /* Routine for installing per-process exception handlers */
  229. EXTERN_API( ExceptionHandler ) InstallExceptionHandler(ExceptionHandler theHandler);
  230.  
  231. #endif  /* TARGET_OS_MAC */
  232.  
  233.  
  234.  
  235. #if PRAGMA_STRUCT_ALIGN
  236.     #pragma options align=reset
  237. #elif PRAGMA_STRUCT_PACKPUSH
  238.     #pragma pack(pop)
  239. #elif PRAGMA_STRUCT_PACK
  240.     #pragma pack()
  241. #endif
  242.  
  243. #ifdef PRAGMA_IMPORT_OFF
  244. #pragma import off
  245. #elif PRAGMA_IMPORT
  246. #pragma import reset
  247. #endif
  248.  
  249. #ifdef __cplusplus
  250. }
  251. #endif
  252.  
  253. #endif /* __MACHINEEXCEPTIONS__ */
  254.  
  255.